<template>
  <el-row>
    <el-col :span="8">
      <el-card class="box-card">
        <div class="user">
          <img src="../assets/images/001.jpg" alt="">
          <div class="userInfo">
            <p class="t-name">{{user.username}}</p>
            <p class="t-access">{{user.userType===1?'超级管理员':'仓库操作员'}}</p>
          </div>
        </div>
      </el-card>
    </el-col>
    <el-col :span="16">
      <div class="num">
        <el-card v-for="item in countData" :key="item.name" :body-style="{ display: 'flex', padding: 0}">
          <i class="icon" :class="`el-icon-${item.icon}`" :style="{ background: item.color }"></i>
          <div class="detail">
            <p class="price">￥{{ item.value }}</p>
            <p class="desc">{{ item.name }}</p>
          </div>
        </el-card>
      </div>
    </el-col>
  </el-row>
</template>

<script>
  import Cookie from 'js-cookie'
  export default {
    data() {
      return {
        user: {
          userType: '',
          username: ''
        },
        tableData: [{
          name: '苹果',
          todybuy: 100,
          mouthbuy: 200,
          totalbuy: 500
        }, {
          name: '华为',
          todybuy: 100,
          mouthbuy: 200,
          totalbuy: 500
        }, {
          name: '小米',
          todybuy: 100,
          mouthbuy: 200,
          totalbuy: 500
        }, {
          name: '魅族',
          todybuy: 100,
          mouthbuy: 200,
          totalbuy: 500
        }],
        countData: [
          {
            name: '今日支付订单',
            value: 1234,
            icon: 'success',
            color: '#2ec7c9',
          },
          {
            name: '今日收藏订单',
            value: 210,
            icon: 'star-on',
            color: '#ffb980',
          },
          {
            name: '今日未支付订单',
            value: 1234,
            icon: 's-goods',
            color: '#5ab1ef',
          },
          {
            name: '本月支付订单',
            value: 1234,
            icon: 'success',
            color: '#2ec7c9',
          },
          {
            name: '本月收藏订单',
            value: 210,
            icon: 'star-on',
            color: '#ffb980',
          },
          {
            name: '本月未支付订单',
            value: 1234,
            icon: 's-goods',
            color: '#5ab1ef',
          },
        ],

      }
    },
    methods: {
      getUserData() {
        this.user.userType = JSON.parse(Cookie.get('user')).userType
        this.user.username = JSON.parse(Cookie.get('user')).username
      }
    },
    mounted() {
      this.getUserData()
    },
  }
</script>

<style lang="less" scoped>
  .user {
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid #ccc;
    display: flex;
    align-items: center;

    img {
      margin-right: 40px;
      height: 150px;
      width: 150px;
      border-radius: 50%;
    }

    .userInfo {
      .t-name {
        font-size: 32px;
        margin-bottom: 10px;
      }

      .t-access {
        color: #999999;
      }
    }
  }

  .num {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;

    .icon {
      width: 80px;
      height: 80px;
      font-size: 30px;
      text-align: center;
      line-height: 80px;
      color: #fff;
    }

    .detail {
      margin-left: 15px;
      display: flex;
      flex-direction: column;
      justify-content: center;

      .price {
        font-size: 30px;
        margin-bottom: 10px;
        line-height: 30px;
        height: 30px;
      }

      .desc {
        font-size: 14px;
        color: #999;
        text-align: center;
      }
    }

    .el-card {
      width: 32%;
      margin-bottom: 20px;
    }
  }
</style>